package com.xucy.springboot.designmodel.behavioral.strategy;

/**
 * @Author xucy
 * @Date 2019-07-28 10:00
 * @Description 策略模式 Comparator  spring-Resource  InstantiationStrategy
 *    应用场景：淘宝有不同的促销活动
 *     1。满减
 *     2。立减
 *     3。返现
 **/

public class Test {

    public static void main(String[] args) {
        //普通的策略，还需要if else判断不同的营销策略
        test1();

        test2(PromotionFactory.PromotionKey.LIJIAN);
    }

    public static void test1(){
        Promotion promotion=new FxPromotion();
        PromotionActivity promotionActivity618=new PromotionActivity(promotion);

        //这个促销策略改变 就可以改变不同的营销策略
        Promotion promotion1=new LjPromotion();
        PromotionActivity promotionActivity1111=new PromotionActivity(promotion1);
        promotionActivity618.promotionExcute();
        promotionActivity1111.promotionExcute();
    }

    /**
     *    工厂模式配合策略模式，实现根据不同的客户端参数，选择不同的策略
     *
     * @Author xucy
     * @Date 10:43 2019-07-28
     * @param
     * @return
     */
    public static void test2(String key){
       Promotion promotion= PromotionFactory.getPromotion(key);
        promotion.promotion();
    }
}
